import logging

from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError

_logger = logging.getLogger(__name__)


class DouyinCollectionCateg(models.Model):
    """合集分类
    """
    _name = 'douyin.collection.categ'
    _description = '合集分类'

    name = fields.Char(string='分类名称')
    code = fields.Char(string='Code', help="网站用这个字段构造合集的访问网址")
    collection_ids = fields.One2many(
        comodel_name='douyin.collection',
        inverse_name='categ_id',
        string='相关合集'
    )

    _sql_constraints = [
        ('uid_code', 'unique (code)', 'Code是唯一的')
    ]
